<?php
include("include/config.inc.php");
$partyIdDelete = 0;
$selectPartyId1 = "SELECT partyId
                     FROM billmaster
                    WHERE partyId = ".$_GET['partyId'];
$selectPartyId1Res = mysql_query($selectPartyId1);
while($partyId1Row = mysql_fetch_array($selectPartyId1Res))
{
	$partyIdDelete = $partyId1Row['partyId'];
}

$selectPartyId2 = "SELECT partyId
                     FROM fixrate
                    WHERE partyId = ".$_GET['partyId'];
$selectPartyId2Res = mysql_query($selectPartyId2);
while($partyId2Row = mysql_fetch_array($selectPartyId2Res))
{
	$partyIdDelete = $partyId2Row['partyId'];
}

$selectPartyId3 = "SELECT partyId
                     FROM incoming
                    WHERE partyId = ".$_GET['partyId'];
$selectPartyId3Res = mysql_query($selectPartyId3);
while($partyId3Row = mysql_fetch_array($selectPartyId3Res))
{
	$partyIdDelete = $partyId3Row['partyId'];
}

$selectPartyId4 = "SELECT partyId
                     FROM planning
                    WHERE partyId = ".$_GET['partyId'];
$selectPartyId4Res = mysql_query($selectPartyId4);
while($partyId4Row = mysql_fetch_array($selectPartyId4Res))
{
	$partyIdDelete = $partyId4Row['partyId'];
}

if($partyIdDelete > 0)
{
	echo "<h1 align='center' style='color:red;'>Your Have to delete all Transaction for this Party</h1>";
	echo "<h1><a style='color:blue; margin-left:50%;' href='party.php'>Back</a></h1>";
}
else
{
	$deleteParty = "DELETE FROM party 
                        WHERE partyId = ".$_GET['partyId'];
  $deletePartyRes = mysql_query($deleteParty);
  if(!$deletePartyRes)
  {
  	echo("DELETE FAIL");
  }
  else
  {
  	header("Location:party.php");
  }
}
?>